<template>
	<view class="content">
		<scroll-view scroll-y="true" class="main">
			<view class="header">
				<image class="icon" src="/static/pages_order/star.png" mode=""></image>
				<view class="text">请对我的服务做出评价！</view>
				<view class="fwjs_box">
					<text class="label">服务技师</text>
					<view class="r">
						<image :src="$oss(avatar)" class="avatar" mode="aspectFill"></image>
						<text>{{name}}</text>
					</view>
				</view>
			</view>
			<view class="ping">
				<text>项目评分</text>
				<view class="stars">
					<u-rate size=30 :count="count" v-model="star"></u-rate>
				</view>
			</view>
			<view class="ping">
				<text>服务评分</text>
				<view class="stars">
					<u-rate size=30 :count="count" v-model="cate_star"></u-rate>
				</view>
			</view>
			<view class="btns">
				<view class="btn" :class="goodlist.includes(i.name)?'act':''" @click="choose(i)"
					v-for="(i,index) in label">{{i.name}}</view>
			</view>
			<view class="textarea_box">
				<textarea name="" id="" v-model="content" cols="30" rows="10" placeholder="请输入评价内容…"></textarea>
			</view>
		</scroll-view>
		<view class="bottom_btn">
			<view class="btn" @click="confirm">评价</view>
		</view>
	</view>
</template>

<script>
	import bottomBtn from '@/components/bottom_btn/bottom_btn.vue'

	export default {
		components: {
			bottomBtn
		},
		data() {
			return {
				count: 5,
				star: 5,
				cate_star: 5,
				value: 2,
				current: 0,
				commentlist: [{
					name: '手法专业',
					id: 1
				}, {
					name: '技师专业',
					id: 2
				}, {
					name: '手法专业1',
					id: 3
				}, {
					name: '手法专业2',
					id: 4
				}, ],
				goodlist: [],
				avatar: '',
				id: '',
				name: '',
				content: '',
				label: ''
			};
		},
		onLoad(option) {
			this.id = option.id
			this.name = option.name
			this.avatar = option.avatar
			this.getLabel()
		},
		methods: {
			getLabel() {
				this.$api.post('/commentlabel').then(res => {
					if (res.code == 1) {
						this.label = res.data
					}
				}).catch((res) => {

				})
			},
			confirm() {
				
				this.$api.post('/comment', {
					id: this.id,
					content: this.content,
					star: this.star,
					cate_star: this.cate_star,
					label_content: this.goodlist.join(','),
					comment_label_ids: ''
				}).then(res => {
					if (res.code == 1) {
						this.$toast(res.msg)
						uni.$emit('orderload')
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/order/order'
							})
						}, 1000)
					}
				}).catch((res) => {

				})
			},
			choose(i) {
				
				if (this.goodlist.includes(i.name)) {
					this.goodlist.splice(this.goodlist.indexOf(i.name), 1)
				} else {
					this.goodlist.push(i.name)
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f7f7fa;
		padding-bottom: 220rpx;
	}

	.content {
		height: 100vh;
		display: flex;
		flex-direction: column;

		.main {
			flex: 1;
			overflow: hidden;
		}
	}

	.bottom_btn {
		width: 750rpx;
		height: 190rpx;
		background: #FFFFFF;
		box-shadow: inset 0rpx 1rpx 0rpx 0rpx #EBEBEB;
		overflow: hidden;
		.btn {
			width: 686rpx;
			height: 96rpx;
			background: $uni-primary;
			border-radius: 48rpx;
			margin: 20rpx auto 0;
			text-align: center;
			line-height: 96rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.header {
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 0rpx 0rpx 30rpx 30rpx;
		padding: 60rpx 32rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;

		.icon {
			width: 134rpx;
			height: 161rpx;
		}

		.text {
			font-size: 44rpx;
			color: #1C274C;
			font-weight: bold;
			margin-top: 30rpx;
		}

		.fwjs_box {
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 686rpx;
			height: 114rpx;
			background: #F6F7FB;
			border-radius: 20rpx;
			padding: 0 32rpx;
			box-sizing: border-box;
			margin: 60rpx auto 0;

			.label {
				font-size: 28rpx;
				color: #3D4666;
			}

			.r {
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-weight: 600;
				color: #1C274C;

				.avatar {
					border-radius: 50%;
					width: 50rpx;
					height: 50rpx;
					margin-right: 20rpx;
				}
			}
		}
	}

	.ping {
		width: 686rpx;
		height: 114rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 32rpx;
		margin: 60rpx auto 0;
		box-sizing: border-box;
		font-size: 30rpx;
		font-weight: 600;
		color: #3D4666;

		image {
			width: 35rpx;
			height: 35rpx;
			margin-left: 20rpx;
		}
	}

	.btns {
		font-size: 26rpx;
		color: #727891;
		display: flex;
		align-items: center;

		padding: 0 32rpx;
		box-sizing: border-box;
		margin-top: 40rpx;
		flex-wrap: wrap;

		.btn {
			padding: 0 10rpx;
			height: 54rpx;
			background: #FFFFFF;
			border-radius: 15rpx;
			line-height: 54rpx;
			text-align: center;
			margin: 0 10rpx 10rpx 0;
		}

		.act {
			background: $uni-primary;
			border-radius: 15rpx;
			color: #fff;
		}
	}

	.textarea_box {
		width: 686rpx;
		min-height: 260rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		margin: 40rpx auto 20rpx;
		padding: 32rpx;
		box-sizing: border-box;

		::v-deep .uni-textarea-textarea,
		.uni-textarea-placeholder {
			font-size: 28rpx;
			color: #3D4666;
		}
	}
</style>